package com.coda.mapper;

import com.coda.annotation.AutoFill;
import com.coda.entity.FeeKey;
import com.coda.entity.FeeValue;
import com.coda.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FeeMapper {
    /**
     * 添加杂费信息
     * @param feeValue
     */
    @AutoFill(OperationType.INSERT)
    void insertValue(FeeValue feeValue);

    /**
     * 更新杂费信息
     * @param feeValue
     */

    @AutoFill(OperationType.UPDATE)
    void updateValue(FeeValue feeValue);

    /**
     * 添加杂费名称
     * @param
     */
    @AutoFill(OperationType.INSERT)
    void insertKey(FeeKey feeKey);

    /**
     * 更新杂费名称
     * @param
     */
    @AutoFill(OperationType.UPDATE)
    void updateKey(FeeKey feeKey);

    /**
     * 获取所有属性名信息
     * @return
     */
    @Select("select * from fee_key")
    List<FeeKey> getFeeKeys();

    /**
     * 通过fee_key_id获取feeValue
     * @param id
     * @return
     */
    @Select("select * from fee_value where fee_key_id = #{id}")
    List<FeeValue> getFeeValues(Long id);

    /**
     * 根据id删除杂费值
     * @param id
     */
    @Delete("delete from fee_value where id = #{id}")
    void deleteValueById(Long id);

    /**
     * 根据id删除杂费名称
     * @param id
     */
    @Delete("delete from fee_key where id = #{id}")
    void deleteKeyById(Long id);

    /**
     * 根据fee_key中的id删除fee_value中的信息
     * @param id
     */
    @Delete("delete from fee_value where fee_key_id = #{id};")
    void deleteValueByKeyId(Long id);
}
